package com.jifeng.br.pjj.bookreader.controller.api;

import com.jifeng.br.pjj.bookreader.service.CodeService;
import com.jifeng.br.pjj.bookreader.service.VipService;
import com.jifeng.br.pjj.bookreader.util.R;
import com.jifeng.br.pjj.bookreader.util.form.LoginForm;
import com.jifeng.br.pjj.bookreader.util.form.RegisterForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author PangJunjie
 * @Date 2023/7/18/018
 */
@RestController
@RequestMapping("/api")
public class LoginApiController {
    @Autowired
    private CodeService codeService;
    @Autowired
    private VipService vipService;

    @GetMapping("/msg")
    public R sendMsg(String phone, String uuid) {
        codeService.sendMsg(phone, uuid);
        return R.ok();
    }

    @PostMapping("/login")
    public R login(@RequestBody LoginForm loginForm) {
        return vipService.login(loginForm);
    }

    @PostMapping("/register")
    public R register(@RequestBody RegisterForm registerForm) {
        vipService.register(registerForm);
        return R.ok();
    }
}
